<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<!--  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"-->

<head th:replace="~{common/header :: header}">
    <title>管理平台</title>
</head>
<body class="layui-layout-body">
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item">
                    <a href="javaScript:void(0)">
                        <i class="layui-icon" id="LAY_app_shrinkButton" lay-filter="shrink"></i>
                    </a>
                </li>
            </ul>
            <ul class="layui-nav layui-layout-right" lay-filter="right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img th:src="@{/images/icon.png}" src="/static/images/icon.png" class="layui-nav-img"/>
                        <!--<span th:text="${username}"></span>-->
                        <!-- <span sec:authentication="name"></span>-->
                        <span sec:authentication="principal.nickname"></span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:void(0);" data-href="user/basicData" id="basicData">基本资料</a></dd>
                        <dd><a href="javascript:void(0);" data-href="user/changePassword" id="changePassword">修改密码</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="/logout" id="logout">退出</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-black layui-side-menu">
            <div class="layui-side-scroll">
                <div class="layui-logo"><span>后台管理</span></div>
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <!--    ==============================           spring security               ====================================     -->

                    <li th:each="permission:${permissions}" th:if="${permission.type}==2" th:id="${permission.code}"
                        class="layui-nav-item">
                        <a href="javascript:void(0);" th:id="${permission.url}" th:class="${permission.code}">
                            <i th:class="${permission.icon}"></i>
                            <cite th:text="${permission.permissionName}"></cite>
                        </a>
                    </li>

                    <li th:each="permission:${permissions}" th:if="${permission.type}==3" th:id="${permission.code}"
                        class="layui-nav-item">
                        <a href="javascript:void(0);">
                            <i th:class="${permission.icon}"></i>
                            <cite th:text="${permission.permissionName}"></cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd th:each="child:${permission.child}" th:id="${child.code}">
                                <a th:if="${child.type}==0" href="javascript:void(0);"
                                   th:text="${child.permissionName}"></a>
                                <dl th:if="${child.type}==0" th:each="grandChild:${child.child}"
                                    class="layui-nav-child">
                                    <dd th:id="${grandChild.code}"><a href="javascript:void(0);"
                                                                      th:text="${grandChild.permissionName}"
                                                                      th:class="${grandChild.code}"
                                                                      th:id="${grandChild.url}"></a></dd>
                                </dl>
                                <a th:if="${child.type}==1" href="javascript:void(0);" th:class="${child.code}"
                                   th:text="${child.permissionName}" th:id="${child.url}"></a>
                            </dd>
                        </dl>
                    </li>
                </ul>
                <!-- <span sec:authentication="principal.authorities"></span>
                 <span sec:authentication="principal.userId"></span>-->
                <!-- <span sec:authorize="hasAuthority('ROLE_PDD')" >sss</span>-->
                <!-- <span sec:authorize="hasRole('PDD')" >ssDFARWs</span>-->
            </div>
        </div>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;" id="body">
            </div>
        </div>
        <div th:replace="~{common/footer::footer}"></div>

    </div>
</div>


<!--用于序号列 递增，（但表头type: 'numbers'也可以）-->
<script th:inline="javascript">
    /*<![CDATA[*/
    <!--    ==============================           spring security               ====================================     -->
    layui.use(['nav'], function () {
        let nav = layui.nav;
        nav.render();
    });

    const permissions = [[${permissions}]];
    page.init = () => {
        $.get(permissions[0].url, function (data) {
            $("#body").html();
            $("#body").html(data);
        });
    };

    window.onload = () => {
        //Hash地址的定位
        let nav = location.hash.replace(/^#nav=/, '').replace(/#.*/, '');
        if (null !== nav && nav.length > 0) {
            let jNav = $("#" + nav);
            jNav.addClass("layui-this");
            if (jNav.parents().length === 11) {
                jNav.parent().parent().addClass("layui-nav-itemed");
                jNav.parent().parent().parent().parent().addClass("layui-nav-itemed");
            }
            if (jNav.parents().length === 9) {
                jNav.parent().addClass("layui-nav-itemed");
                jNav.parent().parent().addClass("layui-nav-itemed");
            }
            $.get($("." + nav).attr("id"), function (data, status) {
                $("#body").empty();
                $("#body").html(data);
            });
        } else page.init();
    };

    // 去掉所有input的autocomplete, 显示指定的除外 
    $(function () {
        $('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
    });


    /*]]>*/
</script>
</body>
</html>
